This sample demonstrates how to create and use XAML UserControl elements and create custom controls for your projects.
Note This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on both Windows 8.1 and Windows Phone 8.1. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see Build apps that target Windows and Windows Phone 8.1 by using Visual Studio.
Specifically, this sample covers:
- Creating an easily reusable composite control with the UserControl class.
- Creating a reusable, custom Control with a default style and template that can be restyled and retemplated as needed.
- Creating custom control properties that depend on other sources for their values. DependencyProperty is useful, for example, to create targets for data binding and animation. For more info, see Dependency properties overview.
- Distributing your control using the Visual Studio Extension SDK.
To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.
To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.
Note For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.
Related topics
- Roadmaps
- Roadmap for C# and Visual Basic
- Samples
- Windows 8 app samples
- Reference
- Control
- UserControl
- DependencyProperty
- Concepts
- Adding and styling controls
- Creating Windows Runtime Components
- Dependency properties overview
- How to: Create a software development kit
- Quickstart: Using global-ready formats
- UX guidelines for apps
Operating system requirements
| Client | |
|---|---|
| Server | |
| Phone |
Build the sample
-
Start Visual Studio and select File > Open > Project/Solution.
-
Go to the directory in which you unzipped the sample. Go to the directory named for the sample, and double-click the Microsoft Visual Studio Solution (.sln) file.
-
Press Ctrl+Shift+B or use Build > Build Solution to build the sample.
Run the sample
To debug the app and then run it, press F5 or use Debug > Start Debugging. To run the app without debugging, press Ctrl+F5 or use Debug > Start Without Debugging.